package com.xz.stu.server.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.xz.stu.server.vo.holiday.*;
import com.xz.stu.server.service.HolidayService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 节假日管理")
@RestController
@RequestMapping("admin-api/school/holiday")
@Validated
public class HolidayController {

    @Resource
    private HolidayService holidayService;

    @PostMapping("/create")
    @Operation(summary = "创建节假日")
    public CommonResult<Long> createHoliday(@Valid @RequestBody HolidayCreateReqVO createReqVO) {
        return success(holidayService.createHoliday(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新节假日")
    public CommonResult<Boolean> updateHoliday(@Valid @RequestBody HolidayUpdateReqVO updateReqVO) {
        holidayService.updateHoliday(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary = "删除节假日")
    public CommonResult<Boolean> deleteHoliday(@PathVariable("id") List<Long> id) {
        holidayService.deleteHoliday(id);
        return success(true);
    }

    @GetMapping("/get/{id}")
    @Operation(summary = "获得节假日")
    public CommonResult<HolidayRespVO> getHoliday(@PathVariable("id") Long id) {
        return success(holidayService.getHoliday(id));
    }

    @GetMapping("/list")
    @Operation(summary = "获得节假日列表")
    public CommonResult<List<HolidayRespVO>> getHolidayList(@Valid HolidayListReqVO listReqVO) {
        return success(holidayService.getHolidayList(listReqVO));
    }
    @GetMapping("/listPage")
    @Operation(summary = "获得节假日列表")
    public CommonResult<PageResult<HolidayRespVO>> getHolidayListPage(@Valid HolidayListPageReqVO listReqVO) {
        return success(holidayService.getHolidayListPage(listReqVO));
    }
}
